#!coding:utf8
# vim: tabstop=4 shiftwidth=4 softtabstop=4
from django.shortcuts import redirect
from django.http import HttpResponse

no_session_action = ['/','/logout','/login']

class CheckSession:
    def process_request(self, request):
        '''
            如果session中没有登录用户信息，跳转到登录页面。
        '''
        path = request.path
        if path not in no_session_action:
            if not request.session.get('user',None):
                return HttpResponse("<script>window.location.href='/logout'</script>")